Skip to content

Add boot4 tests#2261

Open
Vampire wants to merge 1 commit intomasterfrom
boot4-test
Open

Add boot4 tests#2261
Vampire wants to merge 1 commit intomasterfrom
boot4-test

Conversation

@Vampire
Copy link
Copy Markdown
Member

@Vampire Vampire commented Nov 14, 2025

Summary by CodeRabbit

  • New Features

    • Added a Spring Boot 4 test module (now included in non-2.5 build variants) with a bootable app, REST endpoint, request-scoped and regular service examples, and a JPA sample entity + repository
    • Module build configured for Java 17 toolchain
  • Tests

    • Added comprehensive Spock integration tests covering Data JPA, full Spring Boot context, Web MVC endpoints, scoped-bean behavior, and mock/stub scenarios

Copy link
Copy Markdown
Member Author

Vampire commented Nov 14, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.16%. Comparing base (8d380cc) to head (893084a).

Files with missing lines Patch % Lines
...n/java/org/spockframework/boot4/SimpleBootApp.java 60.00% 2 Missing ⚠️
...pockframework/boot4/service/HelloWorldService.java 50.00% 1 Missing ⚠️
...amework/boot4/service/ScopedHelloWorldService.java 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2261   +/-   ##
=========================================
  Coverage     82.16%   82.16%           
- Complexity     4822     4830    +8     
=========================================
  Files           472      477    +5     
  Lines         15036    15054   +18     
  Branches       1905     1905           
=========================================
+ Hits          12354    12369   +15     
- Misses         1989     1993    +4     
+ Partials        693      692    -1     
Files with missing lines Coverage Δ
...c/main/java/org/spockframework/boot4/jpa/Book.java 100.00% <100.00%> (ø)
...spockframework/boot4/web/HelloWorldController.java 100.00% <100.00%> (ø)
...pockframework/boot4/service/HelloWorldService.java 50.00% <50.00%> (ø)
...amework/boot4/service/ScopedHelloWorldService.java 50.00% <50.00%> (ø)
...n/java/org/spockframework/boot4/SimpleBootApp.java 60.00% <60.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

Adds a new spock-spring boot4-test Gradle module: Spring Boot 4 test app, JPA entity/repository, singleton and request-scoped services, REST controller, application properties, build script, and multiple Spock integration tests (Data JPA, Web MVC, scoped/mock scenarios, full-context tests).

Changes

Cohort / File(s) Summary
Build configuration
settings.gradle, spock-spring/boot4-test/boot4-test.gradle
Includes spock-spring:boot4-test in non-2.5 settings; adds new Gradle build script configuring Spring Boot 4, dependency management, Java 17 toolchain, UTF-8 compilation, test runtime deps, and JUnit Platform for tests.
Application entry & controller
spock-spring/boot4-test/src/main/java/org/spockframework/boot4/SimpleBootApp.java, spock-spring/boot4-test/src/main/java/org/spockframework/boot4/web/HelloWorldController.java
New Spring Boot main application and @RestController mapped to / that delegates to HelloWorldService.
Services
spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/HelloWorldService.java, spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/ScopedHelloWorldService.java
Adds singleton HelloWorldService and request-scoped ScopedHelloWorldService (class-proxied) with injected name property and getHelloMessage() methods.
JPA layer
spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/Book.java, spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/BookRepository.java
Adds JPA entity Book and Spring Data CrudRepository<Book, Long>.
Configuration
spock-spring/boot4-test/src/main/resources/application.properties
Adds name=Spock, logging.level.root=OFF, and spring.jpa.hibernate.ddl-auto=create.
Integration tests
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/...
DataJpaTestIntegrationSpec.groovy, SimpleBootAppIntegrationSpec.groovy, SpringBeanIntegrationSpec.groovy, SpringBootTestAnnotationIntegrationSpec.groovy, SpringBootTestAnnotationScopedMockSpec.groovy, SpringBootTestAnnotationScopedProxyMockSpec.groovy, WebMvcTestIntegrationSpec.groovy
Adds multiple Spock specs covering Data JPA slice, full @SpringBootTest, @WebMvcTest with @SpringBean/detached mocks, scoped-bean mock/proxy scenarios, and assertions for bean presence and behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant MockMvc as MockMvc/Test
    participant Controller as HelloWorldController
    participant Service as HelloWorldService
    participant App as SimpleBootApp

    Client->>MockMvc: GET /
    MockMvc->>Controller: invoke hello()
    Controller->>Service: getHelloMessage()
    Service-->>Controller: "Hello Spock"
    Controller-->>MockMvc: response "Hello Spock"
    MockMvc-->>Client: 200 "Hello Spock"
Loading
sequenceDiagram
    participant TestRunner as TestRunner
    participant Spring as SpringBootTest
    participant Repo as BookRepository
    participant H2 as Embedded DB

    TestRunner->>Spring: start test context (SimpleBootApp)
    Spring->>Repo: inject BookRepository
    TestRunner->>Repo: save(Book), save(Book)
    Repo->>H2: persist entities
    H2-->>Repo: persisted
    TestRunner->>Repo: count()
    Repo-->>TestRunner: 2
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • AndreasTu

Poem

🐇 I hopped into boot4 with cheer,
Beans and mocks are drawing near,
Controllers sing and JPA plays,
Tests dance through Spring's sunny days,
A tiny rabbit claps—hip, hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Add boot4 tests" directly and clearly describes the main change: adding a new set of Spring Boot 4 test files and configuration. It accurately reflects the core objective of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch boot4-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Vampire Vampire marked this pull request as ready for review March 13, 2026 04:13
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 13, 2026

Greptile Summary

This PR adds a new boot4-test subproject to validate Spock's Spring integration against Spring Boot 4.x, following the same structural pattern already established by boot3-test. It registers the new subproject in settings.gradle (guarded by the existing Java 17 / non-Groovy-2.5 condition) and ports all seven test specs from boot3boot4, adapting imports and dependency declarations to Spring Boot 4's reorganized module layout.

Key changes:

  • New boot4-test.gradle adds Spring Boot 4.0.3 plugin and introduces two new test-slice starters absent from boot3: spring-boot-starter-data-jpa-test and spring-boot-starter-webmvc-test, reflecting Spring Boot 4's modular test-slice packaging.
  • All test specs are faithfully adapted; the only structural difference from their boot3 counterparts is updated import package paths (e.g. org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest instead of org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest).
  • DataJpaTestIntegrationSpec imports DataJpaTest from org.springframework.boot.data.jpa.test.autoconfigure but TestEntityManager from org.springframework.boot.jpa.test.autoconfigure — the differing package roots (data.jpa vs jpa) are worth double-checking against the actual Spring Boot 4 artifact layout to ensure neither import resolves incorrectly at compile time.

Confidence Score: 4/5

  • This PR is safe to merge; it adds new test infrastructure with no changes to production Spock code.
  • All changes are purely additive test/build files. The structure mirrors the well-established boot3-test subproject. The only item worth a closer look is the split package roots used for DataJpaTest and TestEntityManager in the JPA integration spec, which could fail at compile time if one package path is wrong — but this does not affect any existing functionality.
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy — verify the two different package roots for the JPA test imports.

Important Files Changed

Filename Overview
spock-spring/boot4-test/boot4-test.gradle Gradle build file for Spring Boot 4 integration tests; adds new Spring Boot 4-specific test starters (spring-boot-starter-data-jpa-test, spring-boot-starter-webmvc-test) not present in boot3-test.gradle, correctly targets Java 17 and uses Spring Boot 4.0.3.
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy Uses Spring Boot 4 package paths for DataJpaTest and TestEntityManager, but they come from inconsistent package roots (data.jpa vs jpa) — requires verification against actual Spring Boot 4 module layout.
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBeanIntegrationSpec.groovy Correctly adapted from boot3; uses the new org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest package path for Spring Boot 4; logic is identical to the boot3 equivalent.
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/WebMvcTestIntegrationSpec.groovy Correctly uses new org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest package for Spring Boot 4; otherwise identical structure to boot3's equivalent.
settings.gradle Correctly includes spock-spring:boot4-test inside the non-Groovy-2.5 guard block (alongside boot3-test and spring6-test), which enforces the Java 17 requirement.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    SG[settings.gradle - non-Groovy-2.5 block] --> B3[spock-spring:boot3-test]
    SG --> B4[spock-spring:boot4-test]
    SG --> S6[spock-spring:spring6-test]

    B4 --> GRADLE[boot4-test.gradle - Spring Boot 4.0.3]
    GRADLE --> DEPS[New test starters - data-jpa-test and webmvc-test]

    B4 --> MAIN[Main sources]
    MAIN --> M1[SimpleBootApp]
    MAIN --> M2[HelloWorldService]
    MAIN --> M3[ScopedHelloWorldService]
    MAIN --> M4[HelloWorldController]
    MAIN --> M5[Book and BookRepository]

    B4 --> TESTS[Test specs]
    TESTS --> T1[SimpleBootAppIntegrationSpec]
    TESTS --> T2[SpringBootTestAnnotationIntegrationSpec]
    TESTS --> T3[SpringBeanIntegrationSpec]
    TESTS --> T4[WebMvcTestIntegrationSpec]
    TESTS --> T5[DataJpaTestIntegrationSpec]
    TESTS --> T6[SpringBootTestAnnotationScopedMockSpec]
    TESTS --> T7[SpringBootTestAnnotationScopedProxyMockSpec]
Loading

Last reviewed commit: aa7c7ed

Comment on lines +24 to +25
import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest
import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent package roots for JPA test imports

DataJpaTest is imported from org.springframework.boot.data.jpa.test.autoconfigure while TestEntityManager is imported from org.springframework.boot.jpa.test.autoconfigure — note the difference: data.jpa vs jpa. This inconsistency in the package root is worth verifying against the actual Spring Boot 4 module layout. If both classes ship in the same artifact (spring-boot-starter-data-jpa-test), they are likely in the same or a closely related package tree, and one of these imports may be wrong. The boot3 analogue imported both from org.springframework.boot.test.autoconfigure.orm.jpa.* with a single wildcard import, which naturally avoided this kind of mismatch.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy (1)

52-55: Use Spring's proxy detection API instead of hard-coded internal bean names and generated class prefixes.

The scopedTarget.helloWorldService lookup and $$SpringCGLIB$$ class name prefix check depend on Spring Framework internals and generated class naming conventions. Spring provides standard testing utilities for this: AopUtils.isCglibProxy() to check proxy type semantically, and AopTestUtils.getTargetObject() to safely unwrap the target from the proxy. This pattern appears across the boot2, boot3, and boot4 test suites and should use the standard APIs instead.

Suggested change
-    def helloWorldServiceMock = context.getBean("scopedTarget.helloWorldService") as HelloWorldService
+    def helloWorldServiceMock = AopTestUtils.getTargetObject(helloWorldService)

     expect:
-    helloWorldService.class.simpleName.startsWith('HelloWorldService$$SpringCGLIB$$')
+    AopUtils.isCglibProxy(helloWorldService)

Add imports:

import org.springframework.aop.support.AopUtils
import org.springframework.test.util.AopTestUtils
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy`
around lines 52 - 55, Replace the brittle internal lookup and name-prefix
assertion by using Spring's proxy utilities: stop fetching the bean via
context.getBean("scopedTarget.helloWorldService") and stop asserting on
helloWorldService.class.simpleName; instead import and use
AopUtils.isCglibProxy(helloWorldService) to assert it's a CGLIB proxy and use
AopTestUtils.getTargetObject(helloWorldService) to obtain/unwrap the target for
any further assertions (update references to
helloWorldServiceMock/helloWorldService accordingly).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy`:
- Around line 31-32: The test enables bean definition overriding in the
`@SpringBootTest` annotation (in SpringBootTestAnnotationIntegrationSpec) by
setting the property 'spring.main.allow-bean-definition-overriding=true'; remove
that property from the annotation so the context fails fast on accidental
duplicate beans (i.e., edit the `@SpringBootTest`(...) on the class to drop the
properties array or remove that entry), then re-run the spec to ensure startup
still succeeds.

In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy`:
- Around line 32-33: The test currently uses `@ScanScopedBeans` but tests a
singleton replacement bean (MockConfig.helloWorldService()), so it doesn't
actually verify scoped scanning; either change the replacement bean to a
non-singleton scope (e.g., annotate MockConfig.helloWorldService() as
`@Scope`("prototype") or use a scoped annotation used by
SpringMockTestExecutionListener) and update assertions to target that scoped
bean, or remove `@ScanScopedBeans` from the spec and rename the test class/methods
to indicate it's validating singleton/mock replacement behavior (adjust any
other occurrences at the same locations noted around lines 62-68 accordingly).

---

Nitpick comments:
In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy`:
- Around line 52-55: Replace the brittle internal lookup and name-prefix
assertion by using Spring's proxy utilities: stop fetching the bean via
context.getBean("scopedTarget.helloWorldService") and stop asserting on
helloWorldService.class.simpleName; instead import and use
AopUtils.isCglibProxy(helloWorldService) to assert it's a CGLIB proxy and use
AopTestUtils.getTargetObject(helloWorldService) to obtain/unwrap the target for
any further assertions (update references to
helloWorldServiceMock/helloWorldService accordingly).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a080b41-a247-4a01-aaae-43aa1a5f18bf

📥 Commits

Reviewing files that changed from the base of the PR and between 9c6342c and aa7c7ed.

📒 Files selected for processing (16)
  • settings.gradle
  • spock-spring/boot4-test/boot4-test.gradle
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/SimpleBootApp.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/Book.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/BookRepository.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/HelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/ScopedHelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/web/HelloWorldController.java
  • spock-spring/boot4-test/src/main/resources/application.properties
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SimpleBootAppIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBeanIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/WebMvcTestIntegrationSpec.groovy

Comment on lines +31 to +32
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = ['spring.main.allow-bean-definition-overriding=true'])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Drop bean overriding from this context-load spec.

Nothing in this spec replaces application beans, so enabling spring.main.allow-bean-definition-overriding only weakens the test: an accidental duplicate bean would be silently accepted instead of failing startup.

Suggested cleanup
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
-  properties = ['spring.main.allow-bean-definition-overriding=true'])
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = ['spring.main.allow-bean-definition-overriding=true'])
`@SpringBootTest`(webEnvironment = SpringBootTest.WebEnvironment.NONE)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy`
around lines 31 - 32, The test enables bean definition overriding in the
`@SpringBootTest` annotation (in SpringBootTestAnnotationIntegrationSpec) by
setting the property 'spring.main.allow-bean-definition-overriding=true'; remove
that property from the annotation so the context fails fast on accidental
duplicate beans (i.e., edit the `@SpringBootTest`(...) on the class to drop the
properties array or remove that entry), then re-run the spec to ensure startup
still succeeds.

Comment on lines +32 to +33
@ScanScopedBeans
@SpringBootTest(properties = ['spring.main.allow-bean-definition-overriding=true'])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

@ScanScopedBeans isn't actually under test here.

Per spock-spring/src/main/java/org/spockframework/spring/SpringMockTestExecutionListener.java:94-103, singleton bean definitions are attached even without @ScanScopedBeans; only non-singletons take the scoped-scan path. Since MockConfig.helloWorldService() is a plain singleton @Bean, this spec would still pass if scoped-bean scanning regressed.

Either make the replacement bean scoped or point the assertions at an actual scoped mock; otherwise this should drop @ScanScopedBeans and be renamed to reflect the non-scoped case.

Also applies to: 62-68

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy`
around lines 32 - 33, The test currently uses `@ScanScopedBeans` but tests a
singleton replacement bean (MockConfig.helloWorldService()), so it doesn't
actually verify scoped scanning; either change the replacement bean to a
non-singleton scope (e.g., annotate MockConfig.helloWorldService() as
`@Scope`("prototype") or use a scoped annotation used by
SpringMockTestExecutionListener) and update assertions to target that scoped
bean, or remove `@ScanScopedBeans` from the spec and rename the test class/methods
to indicate it's validating singleton/mock replacement behavior (adjust any
other occurrences at the same locations noted around lines 62-68 accordingly).

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy (1)

31-32: ⚠️ Potential issue | 🟡 Minor

Remove bean-definition overriding from this spec.

Line 31-32 enables bean overriding even though this spec does not replace beans, which can hide accidental duplicate bean registrations.

Suggested cleanup
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
-  properties = ['spring.main.allow-bean-definition-overriding=true'])
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy`
around lines 31 - 32, The `@SpringBootTest` annotation on
SpringBootTestAnnotationIntegrationSpec currently sets properties =
['spring.main.allow-bean-definition-overriding=true']; remove that properties
attribute (or at least remove the 'spring.main.allow-bean-definition-overriding'
entry) so the test no longer enables bean-definition overriding; update the
class annotation (`@SpringBootTest`) accordingly to rely on default behavior and
avoid hiding duplicate bean registrations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy`:
- Around line 31-32: The `@SpringBootTest` annotation on
SpringBootTestAnnotationIntegrationSpec currently sets properties =
['spring.main.allow-bean-definition-overriding=true']; remove that properties
attribute (or at least remove the 'spring.main.allow-bean-definition-overriding'
entry) so the test no longer enables bean-definition overriding; update the
class annotation (`@SpringBootTest`) accordingly to rely on default behavior and
avoid hiding duplicate bean registrations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 644e3f3e-4e26-4ebc-9b12-d49615830984

📥 Commits

Reviewing files that changed from the base of the PR and between aa7c7ed and 682a938.

📒 Files selected for processing (16)
  • settings.gradle
  • spock-spring/boot4-test/boot4-test.gradle
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/SimpleBootApp.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/Book.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/BookRepository.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/HelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/ScopedHelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/web/HelloWorldController.java
  • spock-spring/boot4-test/src/main/resources/application.properties
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SimpleBootAppIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBeanIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/WebMvcTestIntegrationSpec.groovy
✅ Files skipped from review due to trivial changes (6)
  • spock-spring/boot4-test/src/main/resources/application.properties
  • settings.gradle
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/Book.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/BookRepository.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/HelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/ScopedHelloWorldService.java
🚧 Files skipped from review as they are similar to previous changes (7)
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/SimpleBootApp.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/web/HelloWorldController.java
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/WebMvcTestIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBeanIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy

@testlens-app

This comment has been minimized.

@testlens-app
Copy link
Copy Markdown

testlens-app bot commented Mar 21, 2026

🔎 No tests executed 🔎

🏷️ Commit: 893084a
▶️ Tests: 0 executed
🟡 Checks: 59/61 completed


Learn more about TestLens at testlens.app.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy (1)

32-33: ⚠️ Potential issue | 🟠 Major

@ScanScopedBeans is still not actually under test here.

Line 32 enables scoped scanning, but Line 67 defines a default singleton bean, and Line 45 explicitly expects no scopedTarget.helloWorldService. This validates singleton override behavior, not the scoped-bean scan path.

Please either (a) make the replacement bean scoped and assert scoped-target behavior, or (b) remove @ScanScopedBeans and rename the spec to match singleton mock replacement intent.

#!/bin/bash
set -euo pipefail

echo "Verify how scoped scanning is gated in the listener:"
rg -n -C4 'ScanScopedBeans|singleton|scoped|attach.*definition|BeanDefinition' \
  spock-spring/src/main/java/org/spockframework/spring/SpringMockTestExecutionListener.java

echo
echo "Verify this spec currently defines a singleton replacement bean and asserts no scopedTarget bean:"
rg -n -C3 '@ScanScopedBeans|containsBean\\("scopedTarget\\.helloWorldService"\\)|@Bean|HelloWorldService helloWorldService\\(' \
  spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy

Also applies to: 45-46, 62-69

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy`
around lines 32 - 33, The test currently enables `@ScanScopedBeans` but defines a
singleton replacement bean via the helloWorldService `@Bean` and asserts absence
of "scopedTarget.helloWorldService", so the scoped-scan path isn't exercised;
either change the replacement bean to a scoped bean (e.g., make the bean
definition use the same scope that ScanScopedBeans targets so the container
registers a scopedTarget bean) and update the assertions in
SpringBootTestAnnotationScopedMockSpec to expect and verify
"scopedTarget.helloWorldService" behavior, or remove `@ScanScopedBeans` and rename
the spec to reflect singleton replacement intent (keep the helloWorldService
`@Bean` and the existing containsBean("scopedTarget.helloWorldService") negative
assertion). Ensure you update references to helloWorldService, the test class
SpringBootTestAnnotationScopedMockSpec, and the
containsBean("scopedTarget.helloWorldService") assertion accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy`:
- Around line 32-33: The test currently enables `@ScanScopedBeans` but defines a
singleton replacement bean via the helloWorldService `@Bean` and asserts absence
of "scopedTarget.helloWorldService", so the scoped-scan path isn't exercised;
either change the replacement bean to a scoped bean (e.g., make the bean
definition use the same scope that ScanScopedBeans targets so the container
registers a scopedTarget bean) and update the assertions in
SpringBootTestAnnotationScopedMockSpec to expect and verify
"scopedTarget.helloWorldService" behavior, or remove `@ScanScopedBeans` and rename
the spec to reflect singleton replacement intent (keep the helloWorldService
`@Bean` and the existing containsBean("scopedTarget.helloWorldService") negative
assertion). Ensure you update references to helloWorldService, the test class
SpringBootTestAnnotationScopedMockSpec, and the
containsBean("scopedTarget.helloWorldService") assertion accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b11fcf94-f4e6-4586-8fd9-842adaca4b3d

📥 Commits

Reviewing files that changed from the base of the PR and between 682a938 and 893084a.

📒 Files selected for processing (16)
  • settings.gradle
  • spock-spring/boot4-test/boot4-test.gradle
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/SimpleBootApp.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/Book.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/BookRepository.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/HelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/ScopedHelloWorldService.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/web/HelloWorldController.java
  • spock-spring/boot4-test/src/main/resources/application.properties
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SimpleBootAppIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBeanIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/WebMvcTestIntegrationSpec.groovy
✅ Files skipped from review due to trivial changes (8)
  • spock-spring/boot4-test/src/main/resources/application.properties
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/Book.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/jpa/BookRepository.java
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SimpleBootAppIntegrationSpec.groovy
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/web/HelloWorldController.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/SimpleBootApp.java
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/ScopedHelloWorldService.java
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/DataJpaTestIntegrationSpec.groovy
🚧 Files skipped from review as they are similar to previous changes (6)
  • settings.gradle
  • spock-spring/boot4-test/src/main/java/org/spockframework/boot4/service/HelloWorldService.java
  • spock-spring/boot4-test/boot4-test.gradle
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBeanIntegrationSpec.groovy
  • spock-spring/boot4-test/src/test/groovy/org/spockframework/boot4/SpringBootTestAnnotationScopedProxyMockSpec.groovy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant